package com.liu.fresh.biz.impl;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.liu.fresh.biz.IOrderInfoBiz;
import com.liu.fresh.entity.OrderInfo;
import com.liu.fresh.mapper.IOrderInfoMapper;
import com.liu.fresh.util.StringUtil;

@Service
public class OrderInfoBizImpl implements IOrderInfoBiz {
	@Autowired
	private IOrderInfoMapper mapper;

	@Override
	public Integer addOrderInfo(String ono, String odate, String ano, String price) {
		if(StringUtil.checkNull(ono, odate,ano,price)){
			return 0;
		}
		Map<String, Object> map = new HashMap<String, Object>();
		map.put("ono", ono);
		map.put("odate", odate);
		map.put("ano", ano);
		map.put("price", price);
		return mapper.addOrderInfo(map);
	}

	@Override
	public List<OrderInfo> getOrder(String mno) {
		if(StringUtil.checkNull(mno)){
			return null;
		}
		Map<String, Object> map = new HashMap<String, Object>();
		map.put("mno", mno);
		return mapper.getOrder(map);
	}
	@Override
	public List<OrderInfo> getallOrder(String mno) {
		Map<String, Object> map = new HashMap<String, Object>();
		map.put("mno", mno);
		return mapper.getallOrder(map);
	}

	@Override
	public Integer setStatus(String ono) {
		if(StringUtil.checkNull(ono)){
			return 0;
		}
		System.out.println("ono:"+ono);
		System.out.println("修改1");
		Map<String, Object> map = new HashMap<String, Object>();
		map.put("ono", ono);
		return mapper.setStatus(map);
	}

	@Override
	public List<OrderInfo> getOrderByPage(String mno, Integer page) {
		if(StringUtil.checkNull(mno,page)){
			return null;
		}
		Map<String, Object> map = new HashMap<String, Object>();
		map.put("mno", mno);
		map.put("page", (page-1)*2);
		return mapper.getOrderByPage(map);
	}

	@Override
	public Integer getTotal(String mno) {
		if(StringUtil.checkNull(mno)){
			return null;
		}
		Map<String, Object> map = new HashMap<String, Object>();
		map.put("mno", mno);
		return mapper.getTotal(map);
	}

}
